package com.zuowei.ycy.user.adapter;

import android.content.Context;
import android.view.View;
import android.widget.RatingBar;

import com.and.yzy.frame.adapter.AdapterCallback;
import com.and.yzy.frame.adapter.CommonAdapter;
import com.and.yzy.frame.adapter.ViewHolder;
import com.and.yzy.frame.view.dialog.MaterialDialog;
import com.zuowei.ycy.R;
import com.zuowei.ycy.user.domain.CollectGood;

import java.util.List;

/**
 * Created by Administrator on 2016/4/27.
 */
public class CollectAdapter extends CommonAdapter<CollectGood> {

    public CollectAdapter(Context context, List<CollectGood> mDatas, int itemLayoutId, AdapterCallback adapterCallback) {
        super(context, mDatas, itemLayoutId, adapterCallback);
    }

    @Override
    public void convert(ViewHolder holder, final CollectGood item, int positon) {

        holder.setImageByUrl(R.id.iv_good, item.getHead_pic());
        holder.setTextViewText(R.id.tv_name, item.getShop_name());
        RatingBar ratingBar = holder.getView(R.id.rb_pinlun);
        ratingBar.setRating(Float.parseFloat(item.getComment_score()));
        holder.setTextViewText(R.id.tv_lowest_price, "￥" + item.getLowest_price());
        holder.setTextViewText(R.id.tv_delivery_fee, "￥" + item.getDelivery_fee());
        holder.setTextViewText(R.id.tv_del_time, item.getComment_del_time()+"分钟");


        holder.getView(R.id.tv_cancle_collect).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MaterialDialog dialog = new MaterialDialog(mContext);
                dialog.setMDTitle("提示");
                dialog.setMDMessage("确定要取消收藏该商品？");
                dialog.setMDConfirmBtnClick(new MaterialDialog.DialogBtnCallBack() {
                    @Override
                    public void dialogBtnOnClick() {
                        adapterCallback.adapterInfotoActiity(item, 0);
                    }
                });
                dialog.show();
            }
        });
    }
}
